package main

import (
	"fmt"
)

var dict = map[string]int{
	"a": 1,
	"b": 2,

	"z": 26,
}

func rkSearch(main string, pattern string) int {

	//defensive
	if len(main) == 0 || len(pattern) == 0 || len(main) < len(pattern) {
		return -1
	}

	for i := 0; i <= len(main)-len(pattern); i++ {
		subStr := main[i : i+len(pattern)]
		// rk算法 比较hash值
		if hash([]byte(subStr)) == hash([]byte(pattern)) {
			// 考虑hash冲突情况
			if subStr == pattern {
				return i
			}
		}
	}

	return -1
}

func hash(plainText []byte) int {
	return 0
}

func main() {

	main := "abcd227fac"
	pattern := "ac"
	fmt.Println(rkSearch(main, pattern))
}
